package com.huabo.system.oracle.mapper;

import com.hbfk.util.PageInfo;
import com.huabo.system.oracle.entity.TblCourse;
import com.huabo.system.oracle.entity.TblYyUserOrder;
import org.apache.commons.lang.StringUtils;

import java.math.BigDecimal;

public class TblYyUserOrderMapperSqlConifg {
	
	
	public String selectListByPageInfo(PageInfo<TblYyUserOrder> pageInfo) {
		TblYyUserOrder yuo = pageInfo.getCondition();
		StringBuffer sqlSb = new StringBuffer("SELECT * FROM (SELECT BUDGET.*,ROWNUM RN FROM (Select uo.*,S.REALNAME FROM TBL_YY_USER_ORDER uo " +
				" LEFT JOIN TBL_ORGANIZATION o on uo.ORGID = o.ORGID " +
				" LEFT JOIN TBL_STAFF S ON uo.CREATESTAFF = S.STAFFID WHERE uo.ORGID = "+yuo.getOrgid()+" ");
		if(yuo.getOrderno() != null && !"".equals(yuo.getOrderno())){
			sqlSb.append(" AND uo.ORDERNO = '"+yuo.getOrderno()+"'");
		}
		sqlSb.append(" ) BUDGET WHERE rownum <= "+pageInfo.getCurrentRecord()+" ) WHERE RN > "+pageInfo.getPageSize());
		return sqlSb.toString();
	}
	
	public String selectCountByPageInfo(PageInfo<TblYyUserOrder> pageInfo) {
		TblYyUserOrder yuo = pageInfo.getCondition();
		String sqlCount = "Select COUNT(*) FROM TBL_YY_USER_ORDER uo " +
				" LEFT JOIN TBL_ORGANIZATION o on uo.ORGID = o.ORGID " +
				" LEFT JOIN TBL_STAFF S ON uo.CREATESTAFF = S.STAFFID WHERE uo.ORGID = "+yuo.getOrgid()+" ";
		if(yuo.getOrderno() != null && !"".equals(yuo.getOrderno())){
			sqlCount += " AND uo.ORDERNO = "+ yuo.getOrderno();
		}
		return sqlCount;
	}



	

	
}
